home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2002 November / CD 1 / APC0211D1.ISO / workshop / prog / files / ActivePerl-5.6.1.633-MSWin32.msi / _0e93283cd3c59d2ddf532e777994587c < prev    next >
Encoding:
Text File  |  2002-06-17  |  12.7 KB  |  330 lines

  1. /*
  2.  * tkCanvas.h --
  3.  *
  4.  *    Declarations shared among all the files that implement
  5.  *    canvas widgets.
  6.  *
  7.  * Copyright (c) 1991-1994 The Regents of the University of California.
  8.  * Copyright (c) 1994-1995 Sun Microsystems, Inc.
  9.  * Copyright (c) 1998 by Scriptics Corporation.
  10.  *
  11.  * See the file "license.terms" for information on usage and redistribution
  12.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13.  *
  14.  * RCS: @(#) $Id: tkCanvas.h,v 1.3 1998/10/13 18:13:06 rjohnson Exp $
  15.  */
  16.  
  17. #ifndef _TKCANVAS
  18. #define _TKCANVAS
  19.  
  20. #ifndef _TK
  21. #include "tk.h"
  22. #endif
  23.  
  24. #ifndef USE_OLD_TAG_SEARCH
  25. typedef struct TagSearchExpr_s TagSearchExpr;
  26.  
  27. struct TagSearchExpr_s {
  28.     TagSearchExpr *next;        /* for linked lists of expressions - used in bindings */
  29.     Tk_Uid uid;                 /* the uid of the whole expression */
  30.     Tk_Uid *uids;               /* expresion compiled to an array of uids */
  31.     int allocated;              /* available space for array of uids */
  32.     int length;                 /* length of expression */
  33.     int index;                  /* current position in expression evaluation */
  34.     int match;                  /* this expression matches event's item's tags*/
  35. };
  36. #endif /* not USE_OLD_TAG_SEARCH */
  37.  
  38. /*
  39.  * The record below describes a canvas widget.  It is made available
  40.  * to the item procedures so they can access certain shared fields such
  41.  * as the overall displacement and scale factor for the canvas.
  42.  */
  43.  
  44. typedef struct TkCanvas {
  45.     Tk_Window tkwin;        /* Window that embodies the canvas.  NULL
  46.                  * means that the window has been destroyed
  47.                  * but the data structures haven't yet been
  48.                  * cleaned up.*/
  49.     Display *display;        /* Display containing widget;  needed, among
  50.                  * other things, to release resources after
  51.                  * tkwin has already gone away. */
  52.     Tcl_Interp *interp;        /* Interpreter associated with canvas. */
  53.     Tcl_Command widgetCmd;    /* Token for canvas's widget command. */
  54.     Tk_Item *firstItemPtr;    /* First in list of all items in canvas,
  55.                  * or NULL if canvas empty. */
  56.     Tk_Item *lastItemPtr;    /* Last in list of all items in canvas,
  57.                  * or NULL if canvas empty. */
  58.  
  59.     /*
  60.      * Information used when displaying widget:
  61.      */
  62.  
  63.     int borderWidth;        /* Width of 3-D border around window. */
  64.     Tk_3DBorder bgBorder;    /* Used for canvas background. */
  65.     int relief;            /* Indicates whether window as a whole is
  66.                  * raised, sunken, or flat. */
  67.     int highlightWidth;        /* Width in pixels of highlight to draw
  68.                  * around widget when it has the focus.
  69.                  * <= 0 means don't draw a highlight. */
  70.     XColor *highlightBgColorPtr;
  71.                 /* Color for drawing traversal highlight
  72.                  * area when highlight is off. */
  73.     XColor *highlightColorPtr;    /* Color for drawing traversal highlight. */
  74.     int inset;            /* Total width of all borders, including
  75.                  * traversal highlight and 3-D border.
  76.                  * Indicates how much interior stuff must
  77.                  * be offset from outside edges to leave
  78.                  * room for borders. */
  79.     GC pixmapGC;        /* Used to copy bits from a pixmap to the
  80.                  * screen and also to clear the pixmap. */
  81.     int width, height;        /* Dimensions to request for canvas window,
  82.                  * specified in pixels. */
  83.     int redrawX1, redrawY1;    /* Upper left corner of area to redraw,
  84.                  * in pixel coordinates.  Border pixels
  85.                  * are included.  Only valid if
  86.                  * REDRAW_PENDING flag is set. */
  87.     int redrawX2, redrawY2;    /* Lower right corner of area to redraw,
  88.                  * in integer canvas coordinates.  Border
  89.                  * pixels will *not* be redrawn. */
  90.     int confine;        /* Non-zero means constrain view to keep
  91.                  * as much of canvas visible as possible. */
  92.  
  93.     /*
  94.      * Information used to manage the selection and insertion cursor:
  95.      */
  96.  
  97.     Tk_CanvasTextInfo textInfo; /* Contains lots of fields;  see tk.h for
  98.                  * details.  This structure is shared with
  99.                  * the code that implements individual items. */
  100.     int insertOnTime;        /* Number of milliseconds cursor should spend
  101.                  * in "on" state for each blink. */
  102.     int insertOffTime;        /* Number of milliseconds cursor should spend
  103.                  * in "off" state for each blink. */
  104.     Tcl_TimerToken insertBlinkHandler;
  105.                 /* Timer handler used to blink cursor on and
  106.                  * off. */
  107.  
  108.     /*
  109.      * Transformation applied to canvas as a whole:  to compute screen
  110.      * coordinates (X,Y) from canvas coordinates (x,y), do the following:
  111.      *
  112.      * X = x - xOrigin;
  113.      * Y = y - yOrigin;
  114.      */
  115.  
  116.     int xOrigin, yOrigin;    /* Canvas coordinates corresponding to
  117.                  * upper-left corner of window, given in
  118.                  * canvas pixel units. */
  119.     int drawableXOrigin, drawableYOrigin;
  120.                 /* During redisplay, these fields give the
  121.                  * canvas coordinates corresponding to
  122.                  * the upper-left corner of the drawable
  123.                  * where items are actually being drawn
  124.                  * (typically a pixmap smaller than the
  125.                  * whole window). */
  126.  
  127.     /*
  128.      * Information used for event bindings associated with items.
  129.      */
  130.  
  131.     Tk_BindingTable bindingTable;
  132.                 /* Table of all bindings currently defined
  133.                  * for this canvas.  NULL means that no
  134.                  * bindings exist, so the table hasn't been
  135.                  * created.  Each "object" used for this
  136.                  * table is either a Tk_Uid for a tag or
  137.                  * the address of an item named by id. */
  138.     Tk_Item *currentItemPtr;    /* The item currently containing the mouse
  139.                  * pointer, or NULL if none. */
  140.     Tk_Item *newCurrentPtr;    /* The item that is about to become the
  141.                  * current one, or NULL.  This field is
  142.                  * used to detect deletions  of the new
  143.                  * current item pointer that occur during
  144.                  * Leave processing of the previous current
  145.                  * item.  */
  146.     double closeEnough;        /* The mouse is assumed to be inside an
  147.                  * item if it is this close to it. */
  148.     XEvent pickEvent;        /* The event upon which the current choice
  149.                  * of currentItem is based.  Must be saved
  150.                  * so that if the currentItem is deleted,
  151.                  * can pick another. */
  152.     int state;            /* Last known modifier state.  Used to
  153.                  * defer picking a new current object
  154.                  * while buttons are down. */
  155.  
  156.     /*
  157.      * Information used for managing scrollbars:
  158.      */
  159.  
  160.     LangCallback *xScrollCmd;    /* Command prefix for communicating with
  161.                  * horizontal scrollbar.  NULL means no
  162.                  * horizontal scrollbar.  Malloc'ed*/
  163.     LangCallback *yScrollCmd;    /* Command prefix for communicating with
  164.                  * vertical scrollbar.  NULL means no
  165.                  * vertical scrollbar.  Malloc'ed*/
  166.     int scrollX1, scrollY1, scrollX2, scrollY2;
  167.                 /* These four coordinates define the region
  168.                  * that is the 100% area for scrolling (i.e.
  169.                  * these numbers determine the size and
  170.                  * location of the sliders on scrollbars).
  171.                  * Units are pixels in canvas coords. */
  172.     Arg regionArg;        /* The option string from which scrollX1
  173.                  * etc. are derived.  Malloc'ed. */
  174.     int xScrollIncrement;    /* If >0, defines a grid for horizontal
  175.                  * scrolling.  This is the size of the "unit",
  176.                  * and the left edge of the screen will always
  177.                  * lie on an even unit boundary. */
  178.     int yScrollIncrement;    /* If >0, defines a grid for horizontal
  179.                  * scrolling.  This is the size of the "unit",
  180.                  * and the left edge of the screen will always
  181.                  * lie on an even unit boundary. */
  182.  
  183.     /*
  184.      * Information used for scanning:
  185.      */
  186.  
  187.     int scanX;            /* X-position at which scan started (e.g.
  188.                  * button was pressed here). */
  189.     int scanXOrigin;        /* Value of xOrigin field when scan started. */
  190.     int scanY;            /* Y-position at which scan started (e.g.
  191.                  * button was pressed here). */
  192.     int scanYOrigin;        /* Value of yOrigin field when scan started. */
  193.  
  194.     /*
  195.      * Information used to speed up searches by remembering the last item
  196.      * created or found with an item id search.
  197.      */
  198.  
  199.     Tk_Item *hotPtr;        /* Pointer to "hot" item (one that's been
  200.                  * recently used.  NULL means there's no
  201.                  * hot item. */
  202.     Tk_Item *hotPrevPtr;    /* Pointer to predecessor to hotPtr (NULL
  203.                  * means item is first in list).  This is
  204.                  * only a hint and may not really be hotPtr's
  205.                  * predecessor. */
  206.  
  207.     /*
  208.      * Miscellaneous information:
  209.      */
  210.  
  211.     Tk_Cursor cursor;        /* Current cursor for window, or None. */
  212.     char *takeFocus;        /* Value of -takefocus option;  not used in
  213.                  * the C code, but used by keyboard traversal
  214.                  * scripts.  Malloc'ed, but may be NULL. */
  215.     double pixelsPerMM;        /* Scale factor between MM and pixels;
  216.                  * used when converting coordinates. */
  217.     int flags;            /* Various flags;  see below for
  218.                  * definitions. */
  219.     int nextId;            /* Number to use as id for next item
  220.                  * created in widget. */
  221.     Tk_PostscriptInfo psInfo;
  222.                 /* Pointer to information used for generating
  223.                  * Postscript for the canvas.  NULL means
  224.                  * no Postscript is currently being
  225.                  * generated. */
  226.     Tcl_HashTable idTable;    /* Table of integer indices. */
  227.  
  228.     /*
  229.      * Additional information, added by the 'dash'-patch
  230.      */
  231.  
  232.     Tk_State canvas_state;    /* state of canvas */
  233.     Tk_Tile tile;
  234.     Tk_Tile disabledTile;
  235.     Tk_TSOffset tsoffset;
  236. #ifndef USE_OLD_TAG_SEARCH
  237.     TagSearchExpr *bindTagExprs; /* linked list of tag expressions used in bindings */
  238. #endif
  239.     /* pTk additions */
  240.     Tk_Item *activeGroup;        /* Which group item is active */
  241. } TkCanvas;
  242.  
  243. /*
  244.  * Flag bits for canvases:
  245.  *
  246.  * REDRAW_PENDING -        1 means a DoWhenIdle handler has already
  247.  *                been created to redraw some or all of the
  248.  *                canvas.
  249.  * REDRAW_BORDERS -         1 means that the borders need to be redrawn
  250.  *                during the next redisplay operation.
  251.  * REPICK_NEEDED -        1 means DisplayCanvas should pick a new
  252.  *                current item before redrawing the canvas.
  253.  * GOT_FOCUS -            1 means the focus is currently in this
  254.  *                widget, so should draw the insertion cursor
  255.  *                and traversal highlight.
  256.  * CURSOR_ON -            1 means the insertion cursor is in the "on"
  257.  *                phase of its blink cycle.  0 means either
  258.  *                we don't have the focus or the cursor is in
  259.  *                the "off" phase of its cycle.
  260.  * UPDATE_SCROLLBARS -        1 means the scrollbars should get updated
  261.  *                as part of the next display operation.
  262.  * LEFT_GRABBED_ITEM -        1 means that the mouse left the current
  263.  *                item while a grab was in effect, so we
  264.  *                didn't change canvasPtr->currentItemPtr.
  265.  * REPICK_IN_PROGRESS -        1 means PickCurrentItem is currently
  266.  *                executing.  If it should be called recursively,
  267.  *                it should simply return immediately.
  268.  * BBOX_NOT_EMPTY -        1 means that the bounding box of the area
  269.  *                that should be redrawn is not empty.
  270.  */
  271.  
  272. #define REDRAW_PENDING        1
  273. #define REDRAW_BORDERS        2
  274. #define REPICK_NEEDED        4
  275. #define GOT_FOCUS        8
  276. #define CURSOR_ON        0x10
  277. #define UPDATE_SCROLLBARS    0x20
  278. #define LEFT_GRABBED_ITEM    0x40
  279. #define REPICK_IN_PROGRESS    0x100
  280. #define BBOX_NOT_EMPTY        0x200
  281.  
  282. /*
  283.  * Flag bits for canvas items (redraw_flags):
  284.  *
  285.  * FORCE_REDRAW -        1 means that the new coordinates of some
  286.  *                item are not yet registered using
  287.  *                Tk_CanvasEventuallyRedraw(). It should still
  288.  *                be done by the general canvas code.
  289.  */
  290.  
  291. #define FORCE_REDRAW        8
  292.  
  293. /*
  294.  * The following definition is shared between tkCanvPs.c and tkCanvImg.c,
  295.  * and is used in generating postscript for images and windows.
  296.  */
  297.  
  298. typedef struct TkColormapData {    /* Hold color information for a window */
  299.     int separated;        /* Whether to use separate color bands */
  300.     int color;            /* Whether window is color or black/white */
  301.     int ncolors;        /* Number of color values stored */
  302.     XColor *colors;        /* Pixel value -> RGB mappings */
  303.     int red_mask, green_mask, blue_mask;    /* Masks and shifts for each */
  304.     int red_shift, green_shift, blue_shift;    /* color band */
  305. } TkColormapData;
  306.  
  307. #define Tk_CanvasActiveGroup(canvas) ((TkCanvas *) (canvas))->activeGroup
  308.  
  309. #define Tk_CanvasGroupHidden(canvas,itemPtr)               \
  310.  ( Tk_CanvasActiveGroup(canvas) &&                         \
  311.    (itemPtr)->group != Tk_CanvasActiveGroup(canvas)) ||    \
  312.  ( (itemPtr)->group &&                                     \
  313.    (itemPtr)->group != Tk_CanvasActiveGroup(canvas) &&     \
  314.    (itemPtr)->group->state != TK_STATE_ACTIVE )
  315.  
  316. #define Tk_GetItemState(canvas,itemPtr)                         \
  317. (                                                          \
  318.  Tk_CanvasGroupHidden(canvas,itemPtr)                      \
  319.     ? TK_STATE_HIDDEN                                           \
  320.     : (((itemPtr)->state == TK_STATE_NULL)                      \
  321.       ? ((TkCanvas *)(canvas))->canvas_state                    \
  322.       : (itemPtr)->state                                        \
  323.       )                                                         \
  324. )
  325.  
  326.  
  327. EXTERN void        TkGroupRemoveItem _ANSI_ARGS_((Tk_Item *item));
  328.  
  329. #endif /* _TKCANVAS */
  330.